/*
 * NetRayt
 * Copyright (c) 2007-2008 Maciej Nabozny.
 *
 * NetRayt is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * NetRayt is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with NetRayt; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/

#include "client.h"

/******************************************************************************/
/*                       Obsługa listy serwerów                               */
/******************************************************************************/

/*
 * Dodanie nowego serwera do listy
 */
void client::addSrv() {
	// Otwórz okienko z polem do wpisania adresu
	addServer *s = new addServer(this, 0);
	
	s->show();
	s->exec();
	
	// Dodaj komputer do listy serwerów
	servers->insertColumns(0, 1);
	
	QModelIndex idxHost = servers->index(0, 0);
	QModelIndex idxPort = servers->index(1, 0);
	QModelIndex idxCpuf = servers->index(2, 0);
	QModelIndex idxCpuc = servers->index(3, 0);
	QModelIndex idxMem = servers->index(4, 0);
	QModelIndex idxYafray = servers->index(5, 0);
	QModelIndex idxIndigo = servers->index(6, 0);
	QModelIndex idxBlender = servers->index(7, 0);
	
	servers->setData(idxHost, QVariant( s->sInfo.host ));
	servers->setData(idxPort, QVariant( s->sInfo.port ));
	servers->setData(idxCpuf, QVariant( s->sInfo.cpuf ));
	servers->setData(idxCpuc, QVariant( s->sInfo.cpuc ));
	servers->setData(idxMem, QVariant( s->sInfo.mem ));
	servers->setData(idxYafray, QVariant( s->sInfo.yafray ));
	servers->setData(idxBlender, QVariant( s->sInfo.blender ));
	servers->setData(idxIndigo, QVariant( s->sInfo.indigo ));
	
	// Zaktualizuj tabelke
	ui.serverListTable->setModel(servers);
	
	// Usuń okienko
	//delete s;
}

/*
 * Usuniecie serwera z tabelki
 */
void client::removeSrv() {
	QModelIndex c = ui.serverListTable->currentIndex();
	servers->removeColumns(c.column(), 1);
	
	ui.serverListTable->setModel(servers);
}
